
<?php
/**
 * Template Name: Edit Profile 
 * Description: Edit Profile Page
 *
 * @package WordPress
 * @subpackage Immersion
 * @since Immersion 1.0
 
 */
get_header( ); 

$hostname_CrossFit = "localhost";
$database_CrossFit = "quadnips_CF26AppsDev";
$username_CrossFit = "quadnips_26";
$password_CrossFit = "fearless";
$CrossFit = mysql_pconnect($hostname_CrossFit, $username_CrossFit, $password_CrossFit) or trigger_error(mysql_error(),E_USER_ERROR); 

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_MemberProfile = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_MemberProfile = $_SESSION['MM_Username'];
}
mysql_select_db($database_CrossFit, $CrossFit);
$query_MemberProfile = sprintf("SELECT * FROM Members WHERE Email = %s", GetSQLValueString($colname_MemberProfile, "text"));
$MemberProfile = mysql_query($query_MemberProfile, $CrossFit) or die(mysql_error());
$row_MemberProfile = mysql_fetch_assoc($MemberProfile);
$totalRows_MemberProfile = mysql_num_rows($MemberProfile);
 


 ?>
<script type="text/javascript">
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
</script>
<div id="primary" class="full-width">
        

			<div id="content" role="main">

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<header class="entry-header">
		<?php do_action( 'gpp_before_title' ); ?>
		<h1 class="entry-title"><?php the_title(); ?></h1>
			
	</header><!-- .entry-header -->
    <div class="entry-content">
			<form action="http://development.crossfit26.com/process/editprofileprocess.php" method="POST" name="form" onsubmit="MM_validateForm('Name','','R','Email','','RisEmail','Address','','R','City','','R','State','','R','Zip','','R','Phone','','R','EmergencyContact','','R','EmergencyContactPhone','','R');return document.MM_returnValue">
  <table width="600" border="0">
  <tr>
    <td><label for="Name1">Name </label></td>
    <td><input name="Name" type="text" id="Name" value="<?php echo $row_MemberProfile['Name']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="Email">Email Address</label></td>
    <td><input name="Email" type="text" id="Email" value="<?php echo $row_MemberProfile['Email']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="Address">Address </label></td>
    <td><input name="Address" type="text" id="Address" value="<?php echo $row_MemberProfile['Address']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="City">City </label></td>
    <td><input name="City" type="text" id="City" value="<?php echo $row_MemberProfile['City']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="State">State </label></td>
    <td><input name="State" type="text" id="State" value="<?php echo $row_MemberProfile['State']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="Zip">Zip Code</label></td>
    <td><input name="Zip" type="text" id="Zip" value="<?php echo $row_MemberProfile['Zip']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="Phone">Phone Number </label></td>
    <td><input name="Phone" type="text" id="Phone" value="<?php echo $row_MemberProfile['Phone']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="EmergencyContact">Emergency Contact </label></td>
    <td><input name="EmergencyContact" type="text" id="EmergencyContact" value="<?php echo $row_MemberProfile['Emergency_Contact']; ?>" /></td>
  </tr>
  <tr>
    <td><label for="EmergencyContactPhone">Emergency Contact Phone </label></td>
    <td><input name="EmergencyContactPhone" type="text" id="EmergencyContactPhone" value="<?php echo $row_MemberProfile['Emergency_Contact_Phone']; ?>" /></td>
  </tr>
  <input name="ID" type="hidden" value="<?php echo $row_MemberProfile['ID']; ?>" />
</table>
<p><input name="Submit" type="submit" value="Save" /></p>
</form>
</p>
	</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->

			</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); 

mysql_free_result($MemberProfile);
?>
